/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action.retail;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.validator.annotations.VisitorFieldValidator;
import java.util.Map;
import model.Customer;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Thai Ha Cong
 */
public class GetCustomerInfoAction extends ActionSupport implements ModelDriven<Customer>{
    
    private Customer customer = new Customer();
    
    public GetCustomerInfoAction() {
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }
    
    @Action(value = "getCustomerInfo", results = {
        @Result(name = "success", location = "/redirect/rdrProcessOrder.jsp"),
        @Result(name = "input", location = "/processOrder.jsp")
    })
    @Override
    public String execute() throws Exception {
        Map session = ActionContext.getContext().getSession();
        session.put("currentCustomer", customer);
        
        return SUCCESS;
    }

    @Override
    @VisitorFieldValidator(message = "", appendPrefix = false)
    public Customer getModel() {
        return customer;
    }
}